package com.ff.xyh.common.servicebase.config;

import com.google.common.base.Predicates;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * @Auther FF
 * @Date 2022年 09月 18日
 * @Time 01:32
 */

@Configuration
@EnableSwagger2
public class SwaggerCofig {
    @Bean
    public Docket webApiConfig(){
        return new Docket(DocumentationType.SWAGGER_2)
                .groupName("webApi")    //组名
                .apiInfo(webApiInfo())
                .select()
                .paths(Predicates.not(PathSelectors.regex("/admin/.*"))) // 该端口访问时不显示
                .paths(Predicates.not(PathSelectors.regex("/error.*")))
                .paths(Predicates.not(PathSelectors.regex("/post-service/.*")))
                .paths(Predicates.not(PathSelectors.regex("/message-service/.*")))
                .paths(Predicates.not(PathSelectors.regex("/front-user/.*")))
                .paths(Predicates.not(PathSelectors.regex("/access-service/.*")))
                .paths(Predicates.not(PathSelectors.regex("/minio/.*")))

//                .paths(Predicates.and(PathSelectors.regex("/post"))) // 访问时只显示该端口
//                .paths(Predicates.and(PathSelectors.regex("/user")))
//                .paths(Predicates.and(PathSelectors.regex("/post-client.*")))
                .build();
    }
    private ApiInfo webApiInfo(){
        return new ApiInfoBuilder()
                .title("校有汇")
                .description("校有汇-接口API文档中心")
                .version("1.0")
                .contact(new Contact("FF", "http://forestfairy.top", "1274791421@qq.com"))
                .build();
    }

}
